import request from '/@/utils/request';

/**
 * 后端控制路由，isRequestRoutes 为 true，则开启后端控制路由
 */
export function systemApi() {
	return {
		/**
		 * -------------------- 用户管理--------------------------
		 */
		// 获取用户列表
		getUserList: (params?: object) => {
			return request({
				url: '/system/getUserList',
				method: 'get',
				params,
			});
		},
		// 添加or编辑用户
		addUser: (params?: object) => {
			return request({
				url: '/system/saveUser',
				method: 'post',
				data: params,
			});
		},
		// 删除用户
		delUser: (params?: object) => {
			return request({
				url: '/system/delUser',
				method: 'post',
				data: params,
			});
		},

		/**
		 * ---------------------角色管理------------------------
		 */
		// 获取角色列表
		getRoleList: (params?: object) => {
			return request({
				url: '/system/getRoleList',
				method: 'get',
				params,
			});
		},
		// 获取角色列表(不分页)
		getRoleListNopage: () => {
			return request({
				url: '/system/getRoleListNopage',
				method: 'get',
			});
		},
		// 获取某个角色对应的菜单
		getMenuRole: (params?: object) => {
			return request({
				url: '/system/getMenuRole',
				method: 'get',
				params,
			});
		},
		// 添加or编辑角色
		addRole: (params?: object) => {
			return request({
				url: '/system/saveRole',
				method: 'post',
				data: params,
			});
		},
		// 删除角色
		delRole: (params?: object) => {
			return request({
				url: '/system/delRole',
				method: 'post',
				data: params,
			});
		},
		// 保存某个角色的菜单权限
		savePermission: (params?: object) => {
			return request({
				url: '/system/savePermission',
				method: 'post',
				data: params,
			});
		},

		/**
		 * ---------------------菜单管理-------------------
		 */
		// 获取菜单列表
		getMenuList: (params?: object) => {
			return request({
				url: '/system/getMenuList',
				method: 'get',
				params,
			});
		},
		// 添加菜单
		addMenu: (params?: object) => {
			return request({
				url: '/system/saveMenu',
				method: 'post',
				data: params,
			});
		},
		// 删除菜单
		delMenu: (params?: object) => {
			return request({
				url: '/system/delMenu',
				method: 'post',
				data: params,
			});
		},

		/**
		 * ---------------------部门管理---------------------
		 */
		// 获取部门列表
		getDepartmentList: (params?: object) => {
			return request({
				url: '/system/getDepartmentList',
				method: 'get',
				params,
			});
		},
		// 添加or编辑部门
		addDepartment: (params?: object) => {
			return request({
				url: '/system/saveDepartment',
				method: 'post',
				data: params,
			});
		},
		// 删除部门
		delDepartment: (params?: object) => {
			return request({
				url: '/system/delDepartment',
				method: 'post',
				data: params,
			});
		},
	};
}
